# Filename: jit-mda-debug-logs.sh
# Usage: jit-mda-debug-logs.sh <primaryIP> <backupIP> > file.log
# Example: jit-mda-debug-logs.sh 10.0.0.1 10.0.0.2 > progress.log
#
# Helper script that obtains the 4 last log lines from scripts
# jit-mda-create-primary and jit-mda-create-backup
# 
# Allows for easy checking on errors on both servers.

primaryIp=$1
backupIp=$2
REMOTELOG=/root/remote.log
REMOTEERR=/root/remote.err
REMUSLOG=/root/remus.log
REMUSERR=/root/remus.err

echo "  === Primary - $primaryIp ===  "
echo "===== PRIMARY - LOG - `ssh root@$primaryIp stat -c %y $REMOTELOG`"
ssh root@$primaryIp "tail -n 4 $REMOTELOG"
echo ""
echo "===== PRIMARY - ERROR - `ssh root@$primaryIp stat -c %y $REMOTEERR`"
ssh root@$primaryIp "tail -n 4 $REMOTEERR"
echo ""
echo "===== PRIMARY - REMUS - `ssh root@$primaryIp stat -c %y $REMUSLOG`"
ssh root@$primaryIp "tail -n 4 $REMUSLOG"
echo ""
echo "===== PRIMARY - REMUS - ERROR - `ssh root@$primaryIp stat -c %y $REMUSERR`"
ssh root@$primaryIp "tail -n 4 $REMUSERR"
echo ""
echo "  === BackUp - $backupIp ===  "
echo ""
echo "===== BACKUP - LOG - `ssh root@$primaryIp stat -c %y $REMOTELOG`"
ssh root@$backupIp "tail -n 4 $REMOTELOG"
echo ""
echo "===== BACKUP - ERROR - `ssh root@$primaryIp stat -c %y $REMOTEERR`"
ssh root@$backupIp "tail -n 4 $REMOTEERR"
echo ""
echo "===== BACKUP - REMUS - `ssh root@$primaryIp stat -c %y $REMUSLOG`"
ssh root@$backupIp "tail -n 4 $REMUSLOG"
echo ""
echo "===== BACKUP - REMUS - ERROR - `ssh root@$primaryIp stat -c %y $REMUSERR`"
ssh root@$backupIp "tail -n 4 $REMUSERR"
